import requests


class IhrmEmpManage:
    # 定义接口方法
    # 添加员工
    def add_emp(self, req_header, req_body):
        return requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",
                             headers=req_header,
                             json=req_body)

    # 修改员工
    def modify_emp(self, emp_id, req_header, req_body):
        return requests.put(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers=req_header,
                            json=req_body)

    # 查询员工
    def query_emp(self, emp_id, req_header):
        return requests.get(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers=req_header)

    # 删除员工
    def delete_emp(self, emp_id, req_header):
        return requests.delete(url="http://ihrm2-test.itheima.net/api/sys/user/" + emp_id,
                            headers=req_header)


# if __name__ == '__main__':
#     ihrm = IhrmEmpManage()
#     req_header ={'Authorization': '8c0c80d0-97a5-45af-8450-e0894f757a34'}
#     req_data = {
#         "username": "jack123",
#         "mobile": "18983892600",
#         "workNumber": "9527"
#     }
#     req_body = {"username": "刘大锤！"}
#     emp_id = "1650826872705003520"
    # 添加员工 切记改员工电话号
    # resp=ihrm.add_emp(req_header,req_data)
    # print(resp.json())

    # 修改员工 切记改req_body
    # resp = ihrm.modify_emp(emp_id, req_header, req_body)
    # print(resp.json())

    # 查询员工
    # resp = ihrm.query_emp(emp_id, req_header)
    # print(resp.json())

    # 删除员工
    # resp = ihrm.delete_emp(emp_id, req_header)
    # print(resp.json())
